window.onload = function () {
    document.getElementById("system-portal").className = "add_class";
    document.getElementById("sys-home").className = "add-nav-active";
};


function change_time(ele_id) {
    var time=new Date();
    var hour=checkTime(time.getHours());  //获取时
    var minite=checkTime(time.getMinutes()); //获取分
    function checkTime(i){
        if(i<10) return "0"+i;
        return i;
    }
    var work_status = "正常";
    var sign_type = "";
    var work_time = (hour+":"+minite);
    if (ele_id === "上班打卡"){
        sign_type = "上班打卡";
        if (document.getElementById("work_hours").innerText === "--"){
            document.getElementById("work_hours").innerHTML = work_time;
            if (work_time>"08:30") {
                work_status = "迟到";
                document.getElementById("work_work_status").className = "badge badge-pill badge-danger";
            }
            document.getElementById("work_work_status").innerHTML = work_status;
        }else {
            alert("已打过上班卡，请勿重复打卡！")
        }
    }else {
        sign_type = "下班打卡";
        document.getElementById("off_duty").innerHTML = work_time;
        if (work_time<"17:30") {
            work_status = "早退";
            document.getElementById("off_work_status").className = "badge badge-pill badge-danger";

        }
        document.getElementById("off_work_status").innerHTML = work_status;
    }

    var xhr = new XMLHttpRequest();
    var local_host = window.location.host;          // 获取当前IP
    xhr.open('post', "/personal-center/my_attendance.html", true);
    xhr.setRequestHeader('content-type', 'application/x-www-form-urlencoded');
    xhr.send("work_time="+work_time+"&work_status="+work_status+"&sign_type="+sign_type+"&sign_way=电脑");
    xhr.onreadystatechange = function () {
        if (xhr.readyState === 4) {
            if (xhr.status === 200) {
                var JsonDate = JSON.parse(xhr.responseText);
                document.getElementById("loading").style.display = "none";
            }
        }
    };
}


function news_bulletin(ele_id) {
    if (ele_id === "news_photo"){
        document.getElementById(ele_id).className="button-style active-style";
        document.getElementById("notification_announcement").className="button-style";
        document.getElementById("new_model").style.display="inline-block";
        document.getElementById("notice_model").style.display="none";
    }else {
        document.getElementById(ele_id).className="button-style active-style";
        document.getElementById("news_photo").className="button-style";
        document.getElementById("notice_model").style.display="inline-block";
        document.getElementById("new_model").style.display="none";
    }
}
